{extend name="template/order" /}
{block name="content"}
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>订单管理</h3>
      <ul class="tab-base">
        <li><a href="JavaScript:void(0);" class="current"><span>管理</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form method="get" action="{:url('admin/order.order/index')}" name="formSearch" id="formSearch">
    <table class="tb-type1 noborder search">
      <tbody>
        <tr>
         <th><label>订单号</label></th>
         <td><input class="txt2" type="text" name="order_sn" value="<?php echo $_GET['order_sn'];?>" /></td>
         <th>店铺</th>
         <td><input class="txt-short" type="text" name="store_name" value="<?php echo $_GET['store_name'];?>" /></td>
         <th><label>订单状态</label></th>
          <td colspan="4"><select name="order_state" class="querySelect">
              <option value="">请选择</option>
              <option value="10" <?php if($_GET['order_state'] == '10'){?>selected<?php }?>>待付款</option>
              <option value="15" <?php if($_GET['order_state'] == '15'){?>selected<?php }?>>待确认</option>
              <option value="20" <?php if($_GET['order_state'] == '20'){?>selected<?php }?>>待发货</option>
              <option value="30" <?php if($_GET['order_state'] == '30'){?>selected<?php }?>>待收货</option>
              <option value="40" <?php if($_GET['order_state'] == '40'){?>selected<?php }?>>交易完成</option>
              <option value="0" <?php if($_GET['order_state'] == '0'){?>selected<?php }?>>已取消</option>
            </select></td>
        
        </tr>
        <tr>
          <th><label for="query_start_time">下单时间</label></th>
          <td><input class="txt date" type="text" value="<?php echo $_GET['query_start_time'];?>" id="query_start_time" name="query_start_time">
            <label for="query_start_time">~</label>
            <input class="txt date" type="text" value="<?php echo $_GET['query_end_time'];?>" id="query_end_time" name="query_end_time"/></td>
         <th>买家</th>
         <td><input class="txt-short" type="text" name="buyer_name" value="<?php echo $_GET['buyer_name'];?>" /></td> <th>付款方式</th>
         <td>
            <select name="payment_code" class="w100">
            <option value="">请选择</option>
            <?php foreach($payment_list as $val) { ?>
            <option <?php if($_GET['payment_code'] == $val['payment_code']){?>selected<?php }?> value="<?php echo $val['payment_code']; ?>"><?php echo $val['payment_name']; ?></option>
            <?php } ?>
            </select>
         </td>
          <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search " title="查询">&nbsp;</a>
            
            </td>
        </tr>
      </tbody>
    </table>
  </form>
  <table class="table tb-type2" id="prompt">
    <tbody>
      <tr class="space odd">
        <th colspan="12"><div class="title"><h5>操作提示</h5><span class="arrow"></span></div></th>
      </tr>
      <tr>
        <td>
        <ul>
            <li>点击查看操作将显示订单（包括订单物品）的详细信息</li>
            <li>点击取消操作可以取消订单（在线支付但未付款的订单和线下支付但未发货的订单）</li>
            <li>如果平台已确认收到买家的付款，但系统支付状态并未变更，可以点击收到货款操作，并填写相关信息后更改订单支付状态</li>
          </ul></td>
      </tr>
    </tbody>
  </table>
  <!--to do 导出<div style="text-align:right;"><a class="btns" target="_blank" href="index.php?<?php echo $_SERVER['QUERY_STRING'];?>&op=export_step1"><span>导出Excel</span></a></div>-->
  <table class="table tb-type2 nobdb">
    <thead>
        <tr class="thead">
            <th>订单号</th>
            <th>店铺</th>
            <th>买家</th>
            <th class="align-center">下单时间</th>
            <th class="align-center">订单总额</th>
            <th class="align-center">支付方式</th>
            <th class="align-center">订单状态</th>
            <th class="align-center">操作</th>
        </tr>
    </thead>
    <tbody>
      <?php if(count($order_list)>0){?>
      <?php foreach($order_list as $order){?>
      <tr class="hover">
        <td><?php echo $order['order_sn'];?></td>
        <td><?php echo $order['store_name'];?></td>
        <td><?php echo $order['buyer_name'];?></td>
        <td class="nowrap align-center"><?php echo date('Y-m-d H:i:s',$order['add_time']);?></td>
        <td class="align-center"><?php echo $order['order_amount'];?></td>
        <td class="align-center"><?php echo orderPaymentName($order['payment_code']);?></td>
        <td class="align-center"><?php echo orderState($order);?></td>
        <td class="w144 align-center">
            
            <a href="{:url('admin/order.order/show')}?order_id=<?php echo $order['order_id'];?>">查看</a>

            <!-- 取消订单 -->
    		<?php if($order['if_cancel']) {?>
        	| <a href="javascript:void(0)" onclick="if(confirm('您确实要取消该订单吗？')){location.href='/?s=admin/order.order/change_state&state_type=cancel&order_id=<?php echo $order['order_id']; ?>'}">
        	取消</a>
        	<?php }?>

        	<!-- 收款 -->
    		<?php if($order['if_system_receive_pay']) {?>
	        	| <a href="{:url('admin/order.order/change_state')}?state_type=receive_pay&order_id=<?php echo $order['order_id']; ?>">
	        	收到货款</a>
    		<?php }?>
    			
    		<!-- 线下支付确认到款 -->
    		<?php if(intval($order['order_state']) == 15) {?>
	        	| <a href="{:url('admin/order.order/change_state')}?state_type=offline_receive_pay&order_id=<?php echo $order['order_id']; ?>">
	        	确认到款</a>
    		<?php }?>
        	</td>
      </tr>
      <?php }?>
      <?php }else{?>
      <tr class="no_data">
        <td colspan="15">暂无相关记录</td>
      </tr>
      <?php }?>
    </tbody>
    <tfoot>
      <tr class="tfoot">
        <td colspan="15" id="dataFuncs"><div class="pagination"> <?php echo $show_page;?> </div></td>
      </tr>
    </tfoot>
  </table>
</div>
<script type="text/javascript" src="/old/data/resource/js/jquery-ui/jquery.ui.js"></script> 
<script type="text/javascript" src="/old/data/resource/js/jquery-ui/i18n/zh-CN.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="/old/data/resource/js/jquery-ui/themes/ui-lightness/jquery.ui.css"  />
<script type="text/javascript">
$(function(){
    $('#query_start_time').datepicker({dateFormat: 'yy-mm-dd'});
    $('#query_end_time').datepicker({dateFormat: 'yy-mm-dd'});
    $('#ncsubmit').click(function(){
    	$('input[name="op"]').val('index');$('#formSearch').submit();
    });
});
</script> 
{/block}